<template>

  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <el-form ref="form" :model="form" :inline="false" label-position="top" :rules="rules" label-width="90px"
      style="padding-left: 10%;" v-loading="loading">
      <el-row :gutter="20">
        <el-col :span="12" :offset="0">
          <el-form-item label="物流公司:" prop="peisongCompany">
            <el-select v-model="form.peisongCompany" placeholder="请选择物流">
              <el-option v-for="item in logistics_company" :key="item.companyName" :label="item.companyName"
                :value="item.companyName"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" :offset="0">

          <el-form-item label="联系人:" prop="contactUserName">
            <el-input v-model="form.contactUserName"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" :offset="0">
          <el-form-item label="联系电话:" prop="telephone">
            <el-input v-model="form.telephone"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" :offset="0">
          <el-form-item label="提醒天数:" prop="warningDay">
            <el-input type="number" v-model="form.warningDay"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24" :offset="0">
          <el-form-item label="物流描述:" prop="remark">
            <el-input type="textarea" v-model="form.remark" :rows="6"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取消</el-button>
        <el-button type="info" @click="reset">重置</el-button>
        <el-button type="primary" @click="submitForm" :loading="loading">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import logisticsCompany, { getCourierCompany } from '@/api/goods/logisticsCompany';
import modelMixin from '@/mixins/modelMixin'
export default {
  name: "addForm",
  mixins: [modelMixin],
  data() {
    return {
      funcObj: logisticsCompany,//方法对象
      id: null,//必须配置，编辑需要赋值
      open: false,
      title: "",
      form: {},
      logistics_company: [],
      rules: {
        peisongCompany: [
          { required: true, message: "请选择物流公司", trigger: "blur" }
        ],
        warningDay: [
          { required: true, message: "提醒天数不能为空", trigger: "blur" }
        ],
      },
    }
  },
  created() {
    this.getCourierCompany()
  },
  methods: {
    add() {
      this.title = "添加提醒设置";
      this.id = null
      this.open = true;
      this.form = {}
    },
    edit(row) {
      this.open = true;
      this.title = "编辑提醒设置";
      this.getDetail({ id: row.id })
    },
    reset() {
      this.form = {}
    },
    cancel() {
      this.open = false;
    },
    categoryChange(value) {
      this.form.categoryId = value;
    },
    getCourierCompany() {
      getCourierCompany().then(res => {
        this.logistics_company = res
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>